home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 25 / AMIGAplus Sonderheft 25 (2000)(Falke)(DE)(Track 1 of 4)[!].iso / PublicDomain / Spiele / Atoms / ATOMS.ASM < prev    next >
Assembly Source File  |  1999-12-08  |  29KB  |  1,837 lines

  1.  
  2.  
  3. ; Watch out! It's The ATOMS game on the Amiga!!!! Done by Tom. Excellent.
  4.  
  5.  
  6. openlibrary = -552
  7. allocmem = -198
  8. freemem = -210
  9.  
  10. logosize = 40*44*3
  11. memsize = 40*200*4+logosize
  12.  
  13.  
  14. bplcon0 = $100
  15. bplcon1 = $102
  16. bplcon2 = $104
  17. bpl1mod = $108
  18. bpl2mod = $10a
  19. ddfstrt = $92
  20. ddfstop = $94
  21. diwstrt = $8e
  22. diwstop = $90
  23. bpl1pth = $e0
  24. bpl1ptl = $e2
  25. bpl2pth = $e4
  26. bpl2ptl = $e6
  27. bpl3pth = $e8
  28. bpl3ptl = $ea
  29. bpl4pth = $ec
  30. bpl4ptl = $ee
  31. col00 = $180
  32. col01 = $182
  33. col02 = $184
  34. col03 = $186
  35. col04 = $188
  36. col05 = $18a
  37. col06 = $18c
  38. col07 = $18e
  39. col08 = $190
  40. col09 = $192
  41. col10 = $194
  42. col11 = $196
  43. col12 = $198
  44. col13 = $19a
  45. col14 = $19c
  46. col15 = $19e
  47. col16 = $1a0
  48. col17 = $1a2
  49. col18 = $1a4
  50. col19 = $1a6
  51. spr0pth = $120
  52. spr0ptl = $122
  53. spr1pth = $124
  54. spr1ptl = $126
  55. spr2pth = $128
  56. spr2ptl = $12a
  57. spr3pth = $12c
  58. spr3ptl = $12e
  59. spr4pth = $130
  60. spr4ptl = $132
  61. spr5pth = $134
  62. spr5ptl = $136
  63. spr6pth = $138
  64. spr6ptl = $13a
  65. spr7pth = $13c
  66. spr7ptl = $13e
  67.  
  68.  
  69.  
  70.  
  71.  section Atoms+++++++++,CODE_C
  72.  
  73. start:
  74.  lea $dff000,a5
  75.  bsr killsystem
  76.  bsr waitblit
  77.  bsr allocate
  78.  tst.l d0
  79.  beq.s error
  80.  bsr initvars2
  81.  bsr newcopper
  82. playagain:
  83.  jsr mt_init
  84.  bsr initvariables
  85.  bsr askplayers
  86.  bsr initcolours
  87.  st musicflag
  88.  bsr startscreen
  89.  bsr mainloop
  90.  tst.b d4
  91.  beq.s playagain
  92.  bsr waitblit
  93.  bsr oldcopper
  94.  bsr free
  95.  jsr mt_end
  96. error:
  97.  bsr freesystem
  98.  clr.l d0
  99.  rts
  100. waitblit:
  101.  btst #14,2(a5)
  102.  bne.s waitblit
  103.  rts
  104. blankplane:
  105.  btst #14,2(a5)
  106.  bne.s blankplane
  107.  move.l planeaddr,$54(a5)
  108.  clr.w $42(a5)
  109.  clr.w $66(a5)
  110.  move.l #-1,$44(a5)
  111.  move.w #%100000000,$40(a5)
  112.  move.w #200*64+20,$58(a5)
  113.  rts
  114. blankplane2:
  115.  btst #14,2(a5)
  116.  bne.s blankplane2
  117.  move.l planeaddr,$54(a5)
  118.  clr.w $42(a5)
  119.  clr.w $66(a5)
  120.  move.l #-1,$44(a5)
  121.  move.w #%100000000,$40(a5)
  122.  move.w #800*64+20,$58(a5)
  123.  rts
  124.  
  125. askplayers:
  126.  bsr blankplane2
  127.  bsr waitblit
  128.  lea text1,a0
  129.  move.w #40*20,d0
  130.  bsr textoutput
  131.  lea text2,a0
  132.  move.w #40*50+16,d0
  133.  bsr textoutput
  134. wb:
  135.  btst #6,$bfe001
  136.  bne.s wb
  137.  move.w mousex,d0
  138.  move.w mousey,d1
  139.  cmp.w #45,d1
  140.  blt.s wb
  141.  cmp.w #60,d1
  142.  bgt.s wb
  143.  cmp.w #118,d0
  144.  blt.s wb
  145.  moveq #2,d4
  146.  cmp.w #145,d0
  147.  blt.s hit
  148.  moveq #3,d4
  149.  cmp.w #178,d0
  150.  blt.s hit
  151.  moveq #4,d4
  152.  cmp.w #208,d0
  153.  bgt.s wb
  154. hit:
  155.  subq #1,d4
  156.  move.w d4,players
  157.  move.w d4,playerno
  158.  rts
  159.  
  160. textoutput:
  161.  lea font,a2
  162.  move.l planeaddr,a1
  163.  add.w d0,a1
  164. nextchar:
  165.  clr.w d0
  166.  move.b (a0)+,d0
  167.  blt.s endtext
  168.  sub.b #'a',d0
  169.  blt.s space
  170.  add.w d0,d0
  171.  moveq #15,d7
  172.  move.l a1,a3
  173. textloop:
  174.  move.w 0(a2,d0.w),(a3)
  175.  add.w #480/8,d0
  176.  lea 40(a3),a3
  177.  dbf d7,textloop
  178. space:
  179.  lea 2(a1),a1
  180.  bra.s nextchar
  181. endtext:
  182.  rts
  183.  
  184. startscreen:
  185.  cmp.w #1,framecount
  186.  blt.s startscreen
  187.  clr.w framecount
  188.  move.w #1590,d0
  189.  sub.w distance,d0
  190.  move.w d0,rot
  191.  bsr rotateaxis
  192.  bsr blankplane
  193.  bsr drawgrid
  194.  add.w #20,distance
  195.  cmp.w #1610,distance
  196.  ble.s startscreen
  197.  bsr initscreen
  198.  rts
  199.  
  200. rotateaxis:
  201.  move.w rot,d0
  202.  add.w d0,d0
  203.  lea sinewave,a0
  204.  lea 1800(a0),a1
  205.  move.w 0(a1,d0.w),d1
  206.  move.w 0(a0,d0.w),d0
  207.  move.w d0,sin1+2
  208.  move.w d0,sin2+2
  209.  move.w d1,cos1+2
  210.  move.w d1,cos2+2
  211.  rts
  212.  
  213. rotate:
  214.  movem.w d0-1,-(sp)
  215.  move.w d2,d0
  216.  move.w d3,d1
  217. sin1 muls #0,d2
  218. cos1 muls #0,d3
  219.  add.l d2,d3
  220.  asr.l #7,d3
  221. sin2 muls #0,d1
  222. cos2 muls #0,d0
  223.  sub.l d1,d0
  224.  asr.l #7,d0
  225.  move.w d0,d2
  226.  movem.w (sp)+,d0-1
  227.  rts
  228.   
  229. drawgrid:
  230.  lea coords,a0
  231.  move.w (a0)+,d7
  232. nextline:
  233.  move.w (a0)+,d2
  234.  move.w (a0)+,d3
  235.  bsr rotate
  236.  move.w distance,d4
  237.  move.w d2,d0
  238.  move.w d3,d1
  239.  ext.l d0
  240.  ext.l d1
  241.  asl.l #8,d0
  242.  asl.l #8,d1
  243.  divs d4,d0
  244.  divs d4,d1
  245.  add.w #160,d0
  246.  add.w #96,d1
  247.  move.w (a0)+,d2
  248.  move.w (a0)+,d3
  249.  bsr rotate
  250.  move.w distance,d4
  251.  ext.l d2
  252.  ext.l d3
  253.  asl.l #8,d2
  254.  asl.l #8,d3
  255.  divs d4,d2
  256.  divs d4,d3
  257.  add.w #160,d2
  258.  add.w #96,d3
  259.  bsr drawline
  260.  dbf d7,nextline
  261.  rts
  262. initvars2:
  263.  clr.w musicflag
  264.  clr.w colours+6
  265.  st fadeflag
  266.  clr.w slider
  267.  clr.w framecount
  268.  move.w #-16,slider2
  269.  clr.w mousex
  270.  clr.w mousey
  271.  clr.w oldmousex
  272.  clr.w oldmousey
  273.  rts
  274.  
  275. initvariables:
  276.  clr.w xrot
  277.  move.w #650,yrot
  278.  clr.w rot
  279.  clr.w explosion
  280.  move.w #-1,winner
  281.  move.w #20,distance
  282.  clr.w quitflag
  283.  clr.w player
  284.  lea playersin,a0
  285.  move.l #$01010101,(a0)
  286.  lea startdata,a0
  287.  lea enddata,a1
  288. loop10:
  289.  clr.b (a0)+
  290.  cmp.l a0,a1
  291.  bne.s loop10
  292.  lea blocklookup,a0
  293.  lea tiles+32,a1
  294.  move.w #255,d7
  295.  clr.l d2
  296. loop13:
  297.  move.l d2,d3
  298.  divu #19,d3
  299.  move.l d3,d4
  300.  swap d4
  301.  add.w d4,d4
  302.  mulu #38*16,d3
  303.  add.w d4,d3
  304.  lea  0(a1,d3.w),a2
  305.  move.l a2,(a0)+
  306.  add.w #1,d2
  307.  dbf d7,loop13
  308.  rts
  309.  
  310. drawline:
  311.  movem.l d0-7/a0-6,-(sp)
  312.  bsr clipping
  313.  tst.w d5
  314.  bne noline
  315.  moveq #40,d4
  316.  muls d1,d4
  317.  moveq #-$10,d5
  318.  and.w d0,d5
  319.  asr.w #3,d5
  320.  add.w d5,d4
  321.  add.l planeaddr,d4
  322.  clr.l d5
  323.  sub.w d1,d3
  324.  roxl.b #1,d5
  325.  tst.w d3
  326.  bge.s y2gy1
  327.  neg.w d3
  328. y2gy1:
  329.  sub.w d0,d2
  330.  roxl.b #1,d5
  331.  tst.w d2
  332.  bge.s x2gx1
  333.  neg.w d2
  334. x2gx1:
  335.  move.w d3,d1
  336.  sub.w d2,d1
  337.  bge.s dygdx
  338.  exg d2,d3
  339. dygdx:
  340.  roxl.b #1,d5
  341.  tst.w d3
  342.  beq noline
  343. wblit:
  344.  btst #14,2(a5)
  345.  bne.s wblit
  346.  move.b octant_table(pc,d5.w),d5
  347.  add.w d2,d2
  348.  move.w d2,$62(a5)
  349.  sub.w d3,d2
  350.  bgt.s signn1
  351.  or.b #$40,d5
  352. signn1:
  353.  move.w d2,$52(a5)
  354.  sub.w d3,d2
  355.  move.w d2,$64(a5)
  356.  move.w #$8000,$74(a5)
  357.  move.w #$ffff,$72(a5)
  358.  move.w #$ffff,$44(a5)
  359.  and.w #$f,d0
  360.  ror.w #4,d0
  361.  or.w #$bca,d0
  362.  move.w d0,$40(a5)
  363.  move.w d5,$42(a5)
  364.  move.l d4,$54(a5)
  365.  move.l d4,$48(a5)
  366.  move.w #40,$66(a5)
  367.  move.w #40,$60(a5)
  368.  lsl.w #6,d3
  369.  addq #2,d3
  370.  move.w d3,$58(a5)
  371. noline:
  372.  movem.l (sp)+,d0-7/a0-6
  373.  rts
  374. octant_table    dc.b 1,17,9,21,5,25,13,29 
  375.  
  376. initscreen: 
  377.  lea blocksequ,a0
  378.  move.w #59,d7
  379. nextblock6:
  380.  cmp.w #1,framecount
  381.  blt.s nextblock6
  382.  clr.w framecount
  383.  move.w (a0)+,d0
  384.  ext.l d0
  385.  divu #10,d0
  386.  move.l d0,d1
  387.  swap d0
  388.  move.w #19*12,d2
  389.  bsr drawblock
  390.  dbf d7,nextblock6
  391.  lea playersin,a0
  392.  move.w #19*12+2,d2
  393.  clr.w d0
  394.  moveq #6,d1
  395.  move.w players,d7
  396. playerloop:
  397.  bsr drawblock
  398.  addq #1,d0
  399.  addq #1,d2
  400.  dbf d7,playerloop
  401.  rts
  402.  
  403. mainloop:
  404.  cmp.w #1,framecount
  405.  blt.s mainloop
  406.  clr.w framecount
  407.  bsr morphhandle
  408.  bsr leftclick
  409.  bsr playerhandler
  410.  btst #10,$16(a5)
  411.  beq nowinn
  412.  add.w #1,toggler
  413.  and.w #1,toggler
  414.  tst.w quitflag
  415.  beq.s mainloop
  416.  sf musicflag
  417.  jsr mt_end
  418.  lea text3,a0
  419.  move.w #40*8+12,d0
  420.  bsr textoutput
  421.  lea text4,a0
  422.  move.w #40*26+6,d0
  423.  bsr textoutput
  424. wb2:
  425.  btst #6,$bfe001
  426.  bne.s wb2
  427.  cmp.w #25,mousey
  428.  blt.s wb2
  429.  cmp.w #40,mousey
  430.  bgt.s wb2
  431.  cmp.w #230,mousex
  432.  blt.s wb2
  433.  clr.w d4
  434.  cmp.w #260,mousex
  435.  blt.s exit
  436.  st d4
  437.  cmp.w #290,mousex
  438.  bgt.s wb2
  439. exit:
  440.  rts
  441. nowinn:
  442.  st d4
  443.  rts
  444.  
  445. playerhandler:
  446.  move.w player,d0
  447.  lea collook,a0
  448.  add.w d0,d0
  449.  move.w 0(a0,d0.w),pointercol
  450.  rts
  451.  
  452. morphhandle:
  453.  lea sequences,a1
  454.  lea datatable,a2
  455.  lea inusetable,a4
  456.  lea morphtable,a0
  457.  tst.w (a0)
  458.  beq.s nomorphs
  459.  move.w 2(a0),d0
  460.  move.w 4(a0),d1
  461.  move.w d0,d4
  462.  move.w d1,d5
  463.  mulu #10,d5
  464.  add.w d5,d4
  465.  clr.l d5
  466.  move.b 0(a2,d4.w),d5
  467.  add.w d5,d5
  468.  add.w d5,d5
  469.  move.l 0(a1,d5.w),a3
  470.  add.w 6(a0),a3
  471.  add.w #2,6(a0)
  472.  move.w (a3),d2
  473.  blt.s endmorph
  474.  move.w 8(a0),d3
  475.  mulu #19*3,d3
  476.  add.w d3,d2
  477.  bsr drawblock
  478. nomorphs:
  479.  rts
  480. endmorph:
  481.  add.b #1,0(a2,d4.w)
  482.  clr.w (a0)
  483.  clr.b 0(a4,d4.w)
  484.  bsr checkreactions
  485.  bsr rubexplosion
  486.  lea playersin,a0
  487. playerout:
  488.  add.w #1,player
  489.  move.w players,d6
  490.  cmp.w player,d6
  491.  bge.s firstplayer
  492.  clr.w player
  493. firstplayer:
  494.  move.w player,d0
  495.  tst.b 0(a0,d0.w)
  496.  beq.s playerout
  497.  rts
  498.  
  499. noreact:
  500.  rts
  501. checkreactions:
  502.  tst.w quitflag
  503.  bne.s noreact
  504.  movem.l d0-7/a0-6,-(sp)
  505.  move.w d0,d2
  506.  move.w d1,d3
  507.  mulu #10,d3
  508.  add.w d2,d3
  509.  move.w d3,d4
  510.  move.w d0,d2
  511.  move.w d1,d3
  512.  ext.l d2
  513.  ext.l d3
  514.  divu #10,d2
  515.  divu #6,d3
  516.  swap d2
  517.  swap d3
  518.  tst.w d2
  519.  beq.s edge1
  520.  cmp.w #9,d2
  521.  beq.s edge1
  522.  tst.w d3
  523.  beq.s edge2
  524.  cmp.w #5,d3
  525.  beq.s edge2
  526. centre:
  527.  move.w #4,d3
  528.  bra.s checkexplode
  529. edge1:
  530.  tst.w d3
  531.  beq.s corner
  532.  cmp.w #5,d3
  533.  beq.s corner
  534.  bra.s edge3
  535. edge2:
  536.  tst.w d2
  537.  beq.s corner
  538.  cmp.w #9,d2
  539.  beq.s corner
  540. edge3:
  541.  move.w #3,d3
  542.  bra.s checkexplode
  543. corner:
  544.  move.w #2,d3
  545. checkexplode:
  546.  lea datatable,a2
  547.  cmp.b 0(a2,d4.w),d3
  548.  ble.s explode
  549.  movem.l (sp)+,d0-7/a0-6
  550.  rts
  551. explode:
  552.  bsr rubexplosion
  553.  lea ownertable,a3
  554.  lea inusetable,a4
  555.  clr.b 0(a2,d4.w)
  556.  clr.b 0(a4,d4.w)
  557.  clr.b 0(a3,d4.w)
  558.  move.w #19*12+1,d2
  559.  move.w #1,explosion
  560.  move.w d0,explosion+2
  561.  move.w d1,explosion+4
  562.  bsr drawblock
  563. waitframe:
  564.  cmp.w #5,framecount
  565.  blt.s waitframe
  566.  clr.w framecount
  567.  move.w d1,-(sp)
  568.  addq #1,d1
  569.  bsr spread
  570.  subq #2,d1
  571.  bsr spread
  572.  move.w (sp)+,d1
  573.  addq #1,d0
  574.  bsr spread
  575.  subq #2,d0
  576.  bsr spread
  577.  bsr checkforwinner
  578.  movem.l (sp)+,d0-7/a0-6
  579.  rts
  580.  
  581. rubexplosion:
  582.  tst.w exp